﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLT_Public;
using System.Data;

namespace QLT_Data
{
   public  class HoaDonNhap_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_tbl_HDN");
       }
       public DataTable TaoBang(string sql)
       {
           return kn.taoBang(sql);
       }
       public int Insert_HoaDonNhap(HoaDonNhap_Public tenHDN,HoaDonNhap_Public tenCongTy,HoaDonNhap_Public ngayNhap)
       {
           int Nparameter =3;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@TenHDN";
           value[0] = tenHDN.TenHDN;
           name[1] = "TenCongTy";
           value[1] = tenCongTy.TenCongTy;
           name[2] = "@NgayNhap";
           value[2] = ngayNhap.NgayNhap;
           return kn.update("insert_HoaDonNhap", name, value, Nparameter);
       }
       public int Update_HoaDonNhap(HoaDonNhap_Public tenHDN,HoaDonNhap_Public maHDN,HoaDonNhap_Public tenCongTy, HoaDonNhap_Public ngayNhap)
       {
           int Nparameter = 4;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaHDN";
           value[0] = maHDN.MaHDN;
           name[1] = "@TenHDN";
           value[1] = tenHDN.TenHDN;
           name[2] = "TenCongTy";
           value[2] = tenCongTy.TenCongTy;
           name[3] = "NgayNhap";
           value[3] = ngayNhap.NgayNhap;
           return kn.update("update_HoaDonNhap", name, value, Nparameter);
       }
       public int Delete_HoaDonNhap(HoaDonNhap_Public maHDN)
       {
           int Nparameter = 1;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaHDN";
           value[0] = maHDN.MaHDN;
           return kn.update("delete_HoaDonNhap", name, value, Nparameter);
       }

    }
}
